import request from "@/utils/request";
import { CategoryResponseData,AttrResponseData,Attr } from "./type";
enum API {
    C1_URL = 'http://114.115.179.162:8022/prod-api/admin/product/getCategory1',
    C2_URL = 'http://114.115.179.162:8022/prod-api/admin/product/getCategory2/',
    C3_URL = 'http://114.115.179.162:8022/prod-api/admin/product/getCategory3/',
    ATTR_URL = 'http://114.115.179.162:8022/prod-api/admin/product/attrInfoList/',
    ADDORUPDATEATTR_URL='http://114.115.179.162:8022/prod-api/admin/product/saveAttrInfo/',
    DELETEATTR_URL = 'http://114.115.179.162:8022/prod-api/admin/product/deleteAttr/'
}

export const reqC1 = ()=>request.get<any,CategoryResponseData>(API.C1_URL)

export const reqC2 = (category1Id:number | string)=>request.get<any,CategoryResponseData>(API.C2_URL+category1Id)

export const reqC3 = (category2Id:number | string)=>request.get<any,CategoryResponseData>(API.C3_URL+category2Id)

export const reqAttr = (category1Id:number | string,category2Id:number | string,category3Id:number | string)=>request.get<any,AttrResponseData>(API.ATTR_URL+`${category1Id}/${category2Id}/${category3Id}`)

export const reqAddOrUpdateAttr = (data:Attr)=>request.post<any,any>(API.ADDORUPDATEATTR_URL,data)

export const reqRemoveAttr = (attrId:number)=>request.delete<any>(API.DELETEATTR_URL+attrId)